1. Field of the Invention
The present invention relates to technology for updating files stored on recording media such as semi-conductor memories and so forth. In particular, the invention relates to technology for resolving logical inconsistencies between the storage state of data constituting the content of a file and management information relating to the file, that arise when updating of the file is interrupted.
2. Related Art
Conventionally, the management of data stored in the recording area of recording media such as semi-conductor memories, magnetic disks, optical magnetic disks and the like, is realized by a file system. In a file system, the recording area is divided into clusters comprising sets of sectors, which are the smallest physical access units. Data recorded in one or more clusters is managed as a file. Files on recording media managed by a file system can be passed between devices that employ the same file system.
The following description relates to a FAT file system, which is one of the conventional file systems.
The FAT file system is the file system generally used in information processing apparatuses such as personal computers. A characteristic of this file system is the use of a table called a FAT (File Allocation Table) to manage the physical storage locations of data constituting file content and directory entries, which are the management information of files.
FIG. 1 shows the data structure within a recording area according to a FAT file system.
With the FAT file system in FIG. 1, a management information area 100 for managing the recording area of a recording medium is provided at the head of the recording area in terms of logical addresses. A data area 110 for storing data constituting file content (hereinafter “file data”) and the like is located in the recording area after management information area 100.
Management information area 100 is formed from a master boot record (MBR) and partition table 101 storing information for managing the recording area as a plurality of areas called partitions, a partition boot sector 102 storing the management information of individual partitions, FATs 103 and 104 showing the physical storage locations of file data, and a root directory entry 105 storing information that relates to files and/or directories existing below a root directory. Given their importance as areas showing the physical storage locations of file data, FATs 103 and 104 are duplicated and thus have the same content.
Data storage area 110 is managed in clusters, each of which is for storing file data. When the amount of data constituting the content of a single file exceeds the capacity of a single cluster, the data is stored in a plurality of clusters, and the connection between the clusters is managed using link information stored in FATs 103 and 104.
FAT file systems are described in detail, for example, in ISO/IEC9293: 1994, Information technology: Volume and file structure of disk cartridges for information interchange.
FIG. 2 shows a directory entry (i.e. management information relating to a file), FIG. 3 shows a FAT, and FIG. 4 shows data constituting the content of a single file.
The relationship between a directory entry and file data in a FAT file system will now be described using FIGS. 2 to 4.
Directory entry 201 shown in FIG. 2 is stored together with other directory entries in root directory entry 105 and data area 110. Directory entry 201 is management information (i.e. filename, file size, etc.) relating to a single file.
As mentioned above, data area 110 is for storing file data and is managed in cluster-sized units. Attached to each cluster is a cluster number that allows the cluster to be uniquely identified. In order to specify clusters that store data constituting file content, the cluster number of clusters storing the initial part of any data (i.e. “starting cluster number”) is stored in directory entry 201, together with the filename and the file size of the file. As illustrated in FIG. 2, directory entry 201 is formed from a filename “FILE1.TXT”, a starting cluster number “10”, and a file size “60 KB”. This tells us that the initial part of the data constituting the content of the file “FILE1.TXT” is stored in cluster number 10, and that the total size of all of the data constituting the file content is 60 kilobytes.
As mentioned above, when the data of a single file is stored in a plurality of clusters, link information in a FAT is used to specify the cluster number of clusters that succeed the cluster shown by the starting cluster number.
FAT 202 shown in FIG. 3 contains FAT entries, each of which is a field corresponding to a cluster number. Each FAT entry shows whether or not the corresponding cluster is currently being used to record file data. If a cluster does record file data, the corresponding FAT entry stores the cluster number of a succeeding cluster that records data constituting the same file content. If a cluster does not have a succeeding cluster, the FAT entry stores “0xFFF”, for example, as a value signifying the end of the same file data.
In the FIG. 3 example, “11” is stored in the FAT entry corresponding to cluster number 10, showing that cluster number 10 is linked to cluster number 11. Likewise, “12” and “13” are stored in the FAT entries corresponding respectively to clusters numbered 11 and 12, showing that the clusters numbered 10, 11, 12 and 13 are linked together in the stated order. “0xFFF” is stored in the FAT entry corresponding to cluster number 13. Since “0xFFF” signifies the termination of a link, we know that the link starting at cluster number 10 ends at cluster number 13.
The FAT entry corresponding to cluster number 14 stores “0”, indicating that this cluster is a free space area; that is, a cluster to which file data has not been allocated.
FIG. 4 shows data constituting the content of the file “FILE1.TXT” (see FIGS. 2 and 3) as being data 1, data 2, data 3 and data 4 divided between four clusters.
The following description relates to the updating of file content in a FAT file system.
To update file content, information in directory entries and FATs 1 and 2 needs to be rewritten, in addition to writing the new file data to the recording medium. If the updating is interrupted due, for example, to power being cut off to an information processing apparatus that is in the process of updating file content, inconsistencies arise between the state of the actual file data and the management information in the directory entries and FATs 1 and 2. As a result, file storage locations cannot be correctly recognized, making it impossible to access files.
A conventional method proposed for resolving the above inconsistencies caused, for example, by power being cut off to an information processing apparatus partway through updating file content, involves implementing file restoration when the information processing apparatus is next operational. This method is disclosed, for example, in unexamined Japanese patent application publication no. 2002-63057.
According to this conventional method, when the new file content and the old file content prior to updating both exist on the recording medium, the directory entry and FATs are updated in the order FAT 1→directory entry→FAT 2, so as to make them consistent with the new file content. Also, restoration information (e.g. flags) showing the update procedures that have been completed is recorded in specific locations on the recording medium. If processing is interrupted during the updating of FAT 1, FAT 2 is overwritten onto FAT 1 based on the restoration information, to return FAT 1 to a pre-update state. Conversely, if processing is interrupted during the updating of a directory entry and FAT 2, FAT 1 is overwritten onto FAT 2 in addition to updating the directory entry, to conclude the file-update processing. As a result, inconsistencies relating to a file are resolved, allowing file storage locations to be correctly recognized.
However, the restoration information recorded on the recording medium when files are updated according to this conventional technology is only required at abnormal times when inconsistencies relating to files occur.
Thus, in terms of effectively and efficiently utilizing recording media for their primary objective which is recording files, it is preferable not to record information onto recording media that is only useful at abnormal times.